package com.banch.cloud.order.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * order controller
 *
 * @author banch
 * @version 1.0
 * @date 2020/5/22
 */
@Slf4j
@RequestMapping(value = {"/consumer"})
@Controller
public class OrderZKController {

    public static final String INVOKE_URL = "http://cloud-provider-payment";

    @Resource
    private RestTemplate restTemplate;

    @ResponseBody
    @RequestMapping(value = {"/order/get"})
    public String paymentInfo() {

        String result = null;
        try {
            result = restTemplate.getForObject(INVOKE_URL + "/payment/zk", String.class);
        } catch (RestClientException e) {
            log.error("call error:", e);
        }

        return result;
    }

}